package router

import (
	"chatproject/docs"
	"chatproject/service"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func Router() *gin.Engine {
	r := gin.Default()
	docs.SwaggerInfo.BasePath = ""
	//swag 相关
	r.GET("swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	//静态资源
	r.Static("", "")
	r.LoadHTMLGlob("view/**/*")

	//首页
	r.GET("/", service.GetIndex)
	r.GET("/index", service.GetIndex)
	//用户模块
	r.GET("/user", service.GetUserList)   //查
	r.POST("/user", service.CreateUser)   //增
	r.DELETE("/user", service.DeleteUser) //删
	r.PUT("/user", service.UpdateUser)    //改
	//登录功能
	r.POST("/login", service.Login)
	//消息模块
	//发送消息
	r.GET("/message", service.SendMsg)
	r.GET("/usermessage", service.SendUserMsg)
	return r
}
